
import json
import jenkins
import pytest
import yaml
from jenkinsapi.jenkins import Jenkins
import requests
# 远程构建job
# url = "http://cqz:111111@192.168.1.222:8088/job/weather_test/build"
# Jenkins 查询job最后一次执行的
# url = "http://cqz:111111@192.168.1.222:8088/job/weather_test/lastBuild/buildNumber"
# Jenkins API查询任务状态
# url = "http://cqz:111111@192.168.1.222:8088/job/weather_test/24/api/json"
# res = requests.get(url)
# print(json.dumps(res.json(), indent=2))
# print(json.dumps(res, indent=2))

class TestJenkins:
    def setup(self):
        pass
    @pytest.mark.parametrize('url, username, password', yaml.safe_load(open('./testdata_jk.yml', encoding='utf-8')))
    def test_jenkins(self, url, username, password):
        print(url, username, password)
        # job = Jenkins(url, username, password)
        jenkins = Jenkins('http://cqz:111111@192.168.1.222:8088/')
        # print(jenkins['weather_test'])
        print(jenkins.keys())
        print(jenkins['http:/192.168.1.103:8088/0148_iSelenium'].get_jenkins_obj())